<?php
class Access_securities extends CI_Controller {
	/*
	 Controllers that are considered secure extend Secure_area, optionally a $module_id can
	 be set to also check if a user can access a particular module in the system.
	 */
	function __construct($module_id = null) {
		parent::__construct();
		if (!$this -> model_authors -> is_logged_in()) {
			redirect('errors/error-404');
			
			//redirect('welcome/not_found');
		}
		//echo $module_id;
		//exit;
		if (!$this -> model_authors-> has_access_permission($module_id, $this -> model_authors -> get_logged_in_author_info() -> author_id)) {
			redirect('author-accessibility/no-permission-access/' .  $module_id);
		}

		//load up global data
		$logged_in_author_info = $this -> model_authors -> get_logged_in_author_info();
		//$data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
		$data['author_info'] = $logged_in_author_info;
		$this -> load -> vars($data);
	}

	public function is_has_modify_permission($module_id = null) {

		if (!$this -> model_authors -> has_modify_permission($module_id, $this -> model_authors -> get_logged_in_author_info() -> author_id)) {
			redirect('author-accessibility/no-permission-modify/' .  $module_id);
		} else {
			return TRUE;
		}
	}

}
